﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using OnlineShop.Models;
using OnlineShop.Models.ViewModels;

namespace OnlineShop.Controllers
{
    public class BaseController : Controller
    {
        public OSUser CurrentUser
        {
            get 
            {
                if (Session["OSUser"] != null)
                    return (OSUser)Session["OSUser"];
                return null;
            }
        }

        public ShoppingCartModel Cart
        {
            get
            {
                if (Session["Cart"] == null)
                    Session["Cart"] = new ShoppingCartModel();

                return (ShoppingCartModel)Session["Cart"];
            }            
        }

        public ActionResult RedirectToLogin()
        {
            return RedirectToAction("Login", "Account", new { returnUrl = Request.Path });
        }

        public ActionResult RedirectToHome()
        {
            return RedirectToAction("Index", "Home");
        } 
    }
}
